package cn.anzhiyublog.staranimegallery.util;


import cn.anzhiyublog.staranimegallery.exception.GalleryException;
import cn.anzhiyublog.staranimegallery.model.enums.StatusCode;

/**
 * 快捷异常工具
 *
 * @author 安知一只鱼
 */
public class ThrowUtils {
    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if (condition) {
            throw runtimeException;
        }
    }

    public static void throwIf(boolean condition, StatusCode statusCode){
        throwIf(condition, new GalleryException(statusCode));
    }

    public static void throwIf(boolean condition, StatusCode statusCode, String message){
        throwIf(condition, new GalleryException(statusCode, message));
    }
}
